package com.sinven.controller;

import com.sinven.common.ActionResult;
import com.sinven.common.Pager;
import com.sinven.pojo.Teacher;
import com.sinven.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller("frontTeacher")
@RequestMapping("teacher")
public class TeacherController {

    @Autowired
    private TeacherService teacherService;

    @RequestMapping({"/","index.html"})
    public String list(Model model, @RequestParam(value = "curPage",defaultValue = "1")Long curPage){
        Pager<Teacher> pager = teacherService.queryCurPageData(curPage);
        model.addAttribute("pager",pager);
        return "teacher/index";
    }

    @RequestMapping("{id}")
    public String detail(Model model, @PathVariable("id")long id){
        Teacher teacher = teacherService.getTeacherByTid(id);
        model.addAttribute("teacher",teacher);
        return "teacher/detail";
    }

}
